package com.atguigu.lease.common.handler;

import com.atguigu.lease.model.result.Response;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.exception.ExceptionUtils;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;
@Slf4j
@RestControllerAdvice
public class LeaseGlobalExceptionHandler {

    @ExceptionHandler(value = Exception.class)
    public Response exception(Exception e) {
      log.error("捕获到异常：{}" , ExceptionUtils.getStackTrace(e));
      return Response.fail().message(e.getMessage());
    }

}
